home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / games / nerak2.zip / CURRITEM.SCR < prev    next >
Text File  |  1995-09-24  |  41KB  |  1,228 lines

  1. !
  2. ! Script Name: CURRITEM.SCR
  3. !
  4. ! This script may be called by any script (using 'runscript') to handle
  5. ! actions on objects pointed to by the generic CURRITEM object, which
  6. ! may point to any object being carried by a player or NPC character
  7. ! in it's backpack (PLAYER.BP or NPC.PB) or being worn (or wielded)
  8. ! by the same (PLAYER.BODY, PLAYER.WEAPON, NPC.ARMOR, etc)
  9. !
  10. ! You cannot make CURRITEM point to 'OBJECT' since the object is not
  11. ! being carried, so a different script of almost identical structure
  12. ! (called DESCOBJ.SCR) is available for looking at those.
  13. !
  14. ! Before calling this script, you should make sure that the CURRITEM
  15. ! object is pointing to the right object.  Examples follow:
  16. !
  17. ! To 'look' at the weapon being worng by a player:
  18. !    curritem = player.weapon;
  19. !    runscript( player.weapon.script, "CURRITEM", LOOK );
  20. !
  21. ! To 'examine' the currently selected backpack item in an NPC's backpack
  22. !    curritem = npc.bp;
  23. !    runscript( npc.bp.script, "CURRITEM", EXAMINE );
  24. !   
  25. ! To 'examine' the vehicle being used by the party,
  26. !    curritem = group.vehicle;
  27. !    runscript( group.vehicle.script, "CURRITEM", EXAMINE );
  28. !
  29. ! To 'invoke' an scroll in the player's backpack, selecting the item
  30. ! from a menu of all scrolls being carried:
  31. !    L0 = select( player.bp, SCROLL );
  32. !    if L0 >= 0 then
  33. !      ! Note that 'curritem' was set by the select itself, so we don't
  34. !      ! have to assign 'curritem' at all.
  35. !      ! You could say 'curritem = player.bp' if you wanted to make
  36. !      ! it clear you expect curritem to be the currently selected backpack
  37. !      ! item.
  38. !      runscript( curritem.script, "CURRITEM", INVOKE );
  39. !    endif;
  40. ! Remember that the CURRITEM generic object is changed everytime you
  41. ! perform one of the following actions:
  42. ! ACTION                CHANGES TO CURRITEM
  43. ! --------------------  -------------------------------------------
  44. ! vanish(NPC)           if curritem belongs to NPC, it is left undefined
  45. ! curritem = x;         Direct assignment to one of the following:
  46. !                          group.vehicle
  47. !                          npc.bp, npc.body, npc.weapon, ..
  48. !                          player.bp, player.body, player.weapon, ..
  49. ! x = select( .. )      A menu selection from a player's or npc's 
  50. !                          bp or body set's curritem also!
  51. !   
  52. !------------------------------------------------------------------------!
  53. ! :@TALK   ! No talking in this script..
  54. !------------------------------------------------------------------------!
  55. ! :@GET    ! No getting in this script
  56. !------------------------------------------------------------------------!
  57. !------------------------------------------------------------------------!
  58. :@DROP      ! Drop the object on the floor !
  59. !------------------------------------------------------------------------!
  60.   if curritem.count > 1 then
  61.     L(0) = getnum( "How many? ", 0, curritem.count );
  62.     if L(0) > 0 then 
  63.       writeln( "You drop ", L(0), " ", curritem.name, "(s)" );
  64.       drop( curritem, L(0) );  
  65.     else
  66.       writeln( "None." );
  67.     endif;
  68.   else
  69.     writeln( "You drop the ", curritem.name );
  70.     drop( curritem );
  71.   endif;
  72.   STOP;
  73.  
  74. !------------------------------------------------------------------------!
  75. :@EXIT ! Exit a VEHICLE (since this is an object we are talking about..)
  76. !------------------------------------------------------------------------!
  77.   ! Since you can only ride one vehicle at a time, this portion of the
  78.   ! script assumes you want to exit from the vehicle being ridden, so 
  79.   ! we ignore 'curritem' and use 'group.vehicle' directly.
  80.   if group.vehicle.count = 0 then
  81.     writeln("You are already on foot!" );
  82.     STOP;
  83.   endif;
  84.   drop( group.vehicle );
  85.   voice( "Exit", 1000 );
  86.   writeln( "You are now on foot.." );
  87.   STOP;
  88.  
  89. !------------------------------------------------------------------------!
  90. :@WEAR   ! Wearing or wielding stuff
  91. !------------------------------------------------------------------------!
  92.  
  93.   L(0) = 0;  ! Hands needed to hold the item..
  94.  
  95.   on curritem.type goto
  96.    WR_FOOD,     WR_WEAPON,     WR_AMMO,      WR_ARMOR,      WR_SHIELD,
  97.    WR_AMULET,   WR_RING,       WR_POTION,    WR_SCROLL,     WR_STAFF;
  98. !
  99. ! the rest can't be worn, so no need to list them..
  100. !  WR_CHEST,    WR_KEYS,       WR_GEMS,      WR_BOOK,       WR_GOLDSACK,
  101. !  WR_TORCH,    WR_LANTERN,    WR_ROPE,      WR_HOOKS,      WR_MIRROR,
  102. !  WR_SIGN,     WR_VEHICLE
  103. !
  104.  
  105. :WR_FOOD
  106. :WR_AMMO
  107. :WR_POTION
  108. :WR_SCROLL
  109.    writeln( "How do you wear a ", curritem.type, "? " );
  110.    STOP;
  111.  
  112. :WR_WEAPON
  113.    gosub STILLKICKING;
  114.    if (player.class = ELF or player.class = WIZARD or player.class = ARCHER) 
  115.       and curritem.weight > 5 + adjustments(player.str) then
  116.      writeln( "This weapon is too heavy for this character class." );
  117.    elsif player.class = WIZARD and curritem.hands > 1 then
  118.      writeln( "Wizards can only use one-handed weapons" );
  119.    elsif (player.class = WIZARD or player.class = DWARF) and curritem.class = MISSILE then
  120.      writeln( "Wizards and dwarfs can't use non-magical missile weapons" );
  121.    elsif player.weapon.count > 0 then
  122.      writeln( "You must first remove the ", player.weapon.name );
  123.    else
  124.      L(0) = curritem.hands; ! Hands needed to hold the weapon !
  125.      S0 = "wielding";
  126.      goto WR_DOIT;
  127.    endif;
  128.    STOP;
  129.  
  130. :WR_ARMOR
  131.    gosub STILLKICKING;
  132.    if (player.class = ELF or player.class = WIZARD) and
  133.       curritem.weight > 5 + adjustments(player.str) then
  134.      writeln( "This armor is too heavy for an elf or a wizard" );
  135.    elsif player.class = ARCHER and
  136.       curritem.weight > 10 + adjustments(player.str) then
  137.      writeln( "This armor is too cumbersome for an archer" );
  138.    elsif player.armor.count > 0 then
  139.      writeln( "You must first remove the ", player.armor.name );
  140.    else
  141.      S0 = "wearing";
  142.      goto WR_DOIT;
  143.    endif;
  144.    STOP;
  145.  
  146. :WR_SHIELD
  147.    gosub STILLKICKING;
  148.    if player.class = WIZARD or player.class = ARCHER or player.class = DWARF then
  149.      writeln( player.class, "s cannot use a shield!" );
  150.    elsif player.class = ELF and curritem.weight > 5 + adjustments(player.str) then
  151.      writeln( "The shield is too heavy for an ELF." );
  152.    elsif player.shield.count > 0 then
  153.      writeln( "You must first remove the ", player.shield.name );
  154.    else
  155.      L(0) = 1;             ! A shield always needs 1 hand.. !
  156.      S0 = "using";
  157.      goto WR_DOIT;
  158.    endif;
  159.    STOP;
  160.  
  161. :WR_STAFF
  162.    gosub STILLKICKING;
  163.    L(0) = 1;             ! A staff always needs 1 hand.. !
  164.    if player.class = FIGHTER then
  165.      writeln( "Fighters can't use magic staffs." );
  166.    elsif curritem.charges = 0 then
  167.      writeln( "The staff has no charges left.." );
  168.    elsif player.staff.count > 0 then
  169.      writeln( "You must first remove the ", player.staff.name );
  170.    else
  171.      S0 = "holding";
  172.      goto WR_DOIT;
  173.    endif;
  174.    STOP;
  175.  
  176. :WR_AMULET
  177. :WR_RING
  178.    if player.class = FIGHTER then
  179.      writeln( "Fighters can't use magic ", curritem.type, "s." );
  180.    elsif curritem.charges = 0 then
  181.      writeln( "The ", curritem.type, " has no charges left.." );
  182.    elsif curritem.type = AMULET and player.amulet.count > 0 then
  183.      writeln( "You must first remove the ", player.amulet.name );
  184.    elsif curritem.type = RING and player.ring.count > 0 then
  185.      writeln( "You must first remove the ", player.ring.name );
  186.    else
  187.      S0 = "wearing";
  188.      goto WR_DOIT;
  189.    endif;
  190.    STOP;
  191.  
  192. :WR_DOIT
  193.   L(1) = 2; ! Player has 2 hands.. !
  194.   if player.weapon.count then dec( L(1), player.weapon.hands ); endif;
  195.   if player.shield.count then dec( L(1), 1 );                   endif;
  196.   if player.staff.count  then dec( L(1), 1 );                   endif;
  197.   if L(0) > L(1) then
  198.     writeln( "You don't have enough free hands!" );
  199.     STOP;
  200.   endif;
  201.   !
  202.   move( curritem, player.body, 1 );
  203.   if success then
  204.     writeln( "You are now ", s0, " the ", player.body.name );
  205.     if player.body.type = ARMOR or player.body.type = SHIELD then
  206.       if player.armor.cursed or player.shield.cursed then
  207.         player.ac = 0;
  208.       else
  209.         inc(player.ac,player.body.ac);
  210.       endif;
  211.     elsif player.body.type = RING or player.body.type = AMULET then
  212.       if( player.body.charges > 0 ) then
  213.         curritem = player.body;
  214.         gosub M1_INVOKE;
  215.         if curritem.charges < 255 then
  216.           dec( curritem.charges );
  217.         endif;
  218.       else
  219.         writeln( "The ", player.body.type, " has no charges." );
  220.       endif;
  221.     endif;
  222.   endif;
  223.   STOP;
  224.  
  225. !------------------------------------------------------------------------!
  226. :@USE ! Use an object in our backpack...
  227. !------------------------------------------------------------------------!
  228.  
  229.   on curritem.type goto
  230.    USE_FOOD,     USE_WEAPON,     USE_AMMO,      USE_ARMOR,      USE_SHIELD,
  231.    USE_AMULET,   USE_RING,       USE_POTION,    USE_SCROLL,     USE_STAFF,
  232.    USE_CHEST,    USE_KEYS,       USE_GEMS,      USE_BOOK,       USE_GOLDSACK,
  233.    USE_TORCH,    USE_LANTERN,    USE_ROPE,      USE_HOOKS,      USE_MIRROR,
  234.    USE_SIGN,     USE_VEHICLE,    USE_DOOR,      USE_THING;
  235.  
  236.   :USE_THING
  237.   writeln( "I don't know what to do with the ", curritem.name );
  238.   STOP;
  239.  
  240.   :USE_FOOD
  241.   :USE_POTION
  242.   :USE_GEMS
  243.   :USE_SCROLL
  244.      goto @INVOKE;
  245.  
  246.   :USE_AMULET
  247.   :USE_RING
  248.   :USE_ARMOR
  249.   :USE_WEAPON
  250.   :USE_SHIELD
  251.   :USE_STAFF
  252.      goto @WEAR;
  253.  
  254.   :USE_AMMO
  255.      writeln( "Just carry it in your backpack.  If you 'wield' a " );
  256.      writeln( "weapon that uses this type of ammo, it will get used" );
  257.      writeln( "automaticly." );
  258.      STOP;
  259.  
  260.   :USE_CHEST
  261.      ! Unlock the chest !
  262.      if curritem.locktype then
  263.        gosub UNLOCK_OBJECT;
  264.        if curritem.locktype = 0 then
  265.          STOP; 
  266.        endif;
  267.        writeln( "You don't have the right key!  Break the lock?" );
  268.        L0 = select( "Yes", "No" );
  269.        if L0 = 0 then
  270.          if curritem.class <> NORMAL_CHEST then
  271.            writeln( "You can't break this kind of chest." );
  272.          elsif random( 2 + adjustments(player.str) ) > 0 then
  273.            write( "You broke the lock!" );
  274.            if curritem.traptype = 1 then
  275.              voice( "Argh", 1000 );    ! 1000 = DCSOUNDS.VFL !
  276.              writeln( "Argh.. Poison trap!" );
  277.              player.poisoned = 1;
  278.            elsif curritem.traptype > 1 then
  279.              voice( "Explode", 1000 ); ! Play standard sound effect !
  280.              writeln( "Bomb Trap!" );
  281.              dec( player.hp, curritem.damage );
  282.              if player.hp = 0 then
  283.                writeln( player.name, " has died.." );
  284.              endif;
  285.            endif;
  286.            curritem.locktype = 0;
  287.            if curritem.block2 then
  288.              curritem.block = curritem.block2;
  289.            endif;
  290.          else
  291.            writeln( "It doesn't break!" );
  292.          endif;
  293.        else
  294.          writeln( "Ok." );
  295.        endif;
  296.        stats(-1); ! Restore Statistics !
  297.      else
  298.        writeln( "It is not locked.." );
  299.      endif;
  300.      STOP;
  301.  
  302.   :USE_KEYS
  303.      writeln( "All keys are checked when trying to open a door or chest," );
  304.      writeln( "you just have to carry it with you.." );
  305.      STOP;
  306.  
  307.   :USE_BOOK
  308.      goto @LOOK;
  309.  
  310.   :USE_GOLDSACK
  311.      L(1) = getnum("How many gold pieces do you want to put in it?",
  312.                          0, group.gold / 10) * 10;
  313.      if L(1) then
  314.        writeln( "You put ", $L1, " in the bag." );
  315.        inc( curritem.value, L(1) );
  316.        dec( group.gold, L(1) );
  317.      else
  318.        writeln( "Ok.." );
  319.      endif;
  320.      STOP;
  321.  
  322.   :USE_TORCH
  323.   :USE_LANTERN
  324.      writeln( "Save your torches.. I haven't implemented LIGHT yet!" );
  325.      STOP;
  326.  
  327.   :USE_ROPE
  328.      writeln( "After fooling around with it for a while, you manage to" );
  329.      writeln( "get yourself tangled up..." );
  330.      STOP;
  331.  
  332.   :USE_HOOKS
  333.      voice( "Ouch", 1000 );
  334.      writeln( "Ouch! (it's sharp!)" );
  335.      STOP;
  336.  
  337.   :USE_MIRROR
  338.      writeln( "Yes, you are ugly, but that doesn't matter here.." );
  339.      STOP;
  340.  
  341.   :USE_SIGN
  342.      writeln( "If you want to read it, put it back where you found it!" );
  343.      STOP;
  344.  
  345.   :USE_VEHICLE
  346.      writeln( "It would be easyer if you put it down first!" );
  347.      STOP;
  348.  
  349.   :USE_DOOR
  350.      writeln( "Why are you carrying a door?" );
  351.      STOP;
  352.  
  353. !------------------------------------------------------------------------!
  354. :@REMOVE ! Remove an item being worn...
  355. !------------------------------------------------------------------------!
  356.  
  357.   if curritem.cursed then
  358.     writeln( "The ", curritem.type, " is cursed and cannot be removed.." );
  359.     STOP;
  360.   endif;
  361.  
  362.   if player.hp = 0 then
  363.     writeln( player.name, " is dead." );
  364.     STOP;
  365.   endif;
  366.  
  367.   if curritem.type = ARMOR or curritem.type = SHIELD then
  368.     if player.ac > curritem.ac then
  369.       dec(player.ac,curritem.ac);
  370.     else
  371.       player.ac = 0;
  372.     endif;
  373.   elsif curritem.type = RING or curritem.type = AMULET then
  374. writeln("ITEM=",curritem.name," TYPE=", curritem.type, " P=", curritem.permanent );
  375.     if not curritem.permanent then
  376. writeln( "CURRITEM.CLASS=",curritem.class," AC = ", PLUS_AC );
  377.        on curritem.class goto
  378.          XNON, XNON, XNON, XNON, XNON,
  379.          X_STR, X_DEX, X_SPD, X_AIM, X_AC, X_HP, X_IQ, X_PWR;
  380.        goto XNON;
  381.  
  382.        :X_STR if player.str > curritem.units then
  383.                dec(player.str,curritem.units);
  384.              else
  385.                player.str = 0;
  386.              endif;
  387.              goto :XNON;
  388.        :X_DEX if player.DEX > curritem.units then
  389.                dec(player.DEX,curritem.units);
  390.              else
  391.                player.DEX = 0;
  392.              endif;
  393.              goto :XNON;
  394.        :X_SPD if player.SPD > curritem.units then
  395.                dec(player.SPD,curritem.units);
  396.              else
  397.                player.SPD = 0;
  398.              endif;
  399.              goto :XNON;
  400.        :X_AIM if player.AIM > curritem.units then
  401.                dec(player.AIM,curritem.units);
  402.              else
  403.                player.AIM = 0;
  404.              endif;
  405.              goto :XNON;
  406.        :X_AC if player.AC > curritem.units then
  407.                dec(player.AC,curritem.units);
  408.              else
  409.                player.AC = 0;
  410.              endif;
  411.              goto :XNON;
  412.        :X_HP if player.hp > player.mhp then
  413.                if player.hp - curritem.units > player.mhp then
  414.                  dec(player.hp,curritem.units);
  415.                else
  416.                  player.hp = player.mhp; ! No lower than regular max !
  417.                endif;
  418.              endif;
  419.              goto :XNON;
  420.        :X_IQ if player.IQ > curritem.units then
  421.                dec(player.IQ,curritem.units);
  422.              else
  423.                player.IQ = 0;
  424.              endif;
  425.              goto :XNON;
  426.        :X_PWR if player.PWR > curritem.units then
  427.                dec(player.PWR,curritem.units);
  428.              else
  429.                player.PWR = 0;
  430.              endif;
  431.              goto :XNON;
  432.     endif;
  433.     writeln( "BEFORE XNON");
  434. :XNON
  435.     writeln( "AFTER XNON");
  436.   endif;
  437.  
  438.   move( curritem, player.bp, 1 );
  439.   if failure then
  440.     writeln( "ERROR: Couldn't take off the ", curritem.name );
  441.   else
  442.     writeln( player.name, " takes off the ", player.bp.name );
  443.   endif;
  444.   STOP;
  445.  
  446. !------------------------------------------------------------------------!
  447. :@LOOK     ! Finally something we can do!!!! 
  448. !------------------------------------------------------------------------!
  449.   L(255) = FALSE;   ! Set a flag so the subroutine does not give a 
  450.                     ! full description (i.e. LOOK, not EXAMINE)
  451.   gosub DESCRIBE;
  452.   STOP;
  453.  
  454. !------------------------------------------------------------------------!
  455. :@EXAMINE   ! Examine the object in detail                               !
  456. !------------------------------------------------------------------------!
  457.   L(255) = TRUE;   ! Give DETAILED description !
  458.   gosub DESCRIBE;
  459.   STOP;
  460.  
  461. !------------------------------------------------------------------------!
  462. :@INVOKE    ! Invoke an object's magical properties
  463. !------------------------------------------------------------------------!
  464.  
  465. ! Called to use an an object in the current player's backpack.  The
  466. ! action varies depending on the type of object.  For example, food
  467. ! is consumed, potions, amulets, scrolls, etc.  have their magical
  468. ! effect invoked.
  469.  
  470.   gosub STILLKICKING;
  471.   if curritem.endgame = END_ON_USE then
  472.     if curritem.endtext > 0 then         ! .. this text is displayed first.. !
  473.       readtext( curritem.endtext );
  474.     endif;                             ! .. then the game ends. !
  475.     ENDGAME;
  476.   endif;
  477.   if curritem.type = FOOD or curritem.type = POTION then
  478.     player.energy = 255;     ! Not hungry any more.. 
  479.     gosub M1_INVOKE;
  480.     if curritem.type = POTION and curritem.count > 1 then
  481.       curritem.name = curritem.class;
  482.     endif;
  483.     dec( curritem.count );
  484.   elsif curritem.type = SCROLL or curritem.type = STAFF then
  485.     gosub M2_INVOKE;
  486.   elsif curritem.type = GEMS or curritem.type = RING or curritem.type = AMULET then
  487.     gosub M1_INVOKE;
  488.     if curritem.charges < 255 then
  489.       dec( curritem.charges );
  490.       if curritem.count > 1 then
  491.         curritem.name = curritem.class;
  492.       endif;
  493.       if curritem.type = GEMS and curritem.charges = 0 then
  494.         writeln( "The ", curritem.type, " vanishes after you use it." );
  495.         dec( curritem.count );
  496.       endif;
  497.     endif;
  498.   else
  499.     writeln( "The ", curritem.name, " has no magical properties.." );  
  500.   endif;
  501.   STOP;
  502.  
  503. !------------------------------------------------------------------------!
  504. !--  SCRIPT SUBROUTINES ARE GROUPED HERE AT THE END.  THIS IS A CHOICE --!
  505. !--  NOT A REQUIREMENT.  IT MAKES THE MAIN SCRIPT CODE ABOVE A LITTLE  --!
  506. !--  BIT EASIER TO FOLLOW.  ---------------------------------------------!
  507. !------------------------------------------------------------------------!
  508.  
  509.  
  510. !------------------------------------------------------------------------!
  511. ! STILLKICKING: Subroutine to verify that the player is alive before     !
  512. ! allowing him/her/it to perform an action.                              !
  513. !------------------------------------------------------------------------!
  514. :STILLKICKING
  515.   if player.hp = 0 then
  516.     writeln( player.name, " is dead!" );
  517.     STOP;
  518.   endif;
  519.   RETURN;
  520.  
  521.  
  522. !------------------------------------------------------------------------!
  523. !
  524. ! SUBROUTINE: DESCRIBE
  525. !
  526. ! This routine is invoked from @LOOK, @EXAMINE 
  527. !
  528. !------------------------------------------------------------------------!
  529. :DESCRIBE
  530. !------------------------------------------------------------------------!
  531.  
  532.   if curritem.count = 0 then
  533.     writeln( "DBG: Opps. There is nothing to look at in CURRITEM.SCR" );
  534.     STOP;
  535.   endif;
  536.   if curritem.picture >= 0 then
  537.     viewpcx( curritem );
  538.     if success then
  539.       pause;
  540.     endif;
  541.     paint(window); ! Assumes the picture fits in the window !
  542.   elsif curritem.type = SIGN or curritem.type = BOOK then
  543.     readtext( curritem.text );
  544.     STOP;
  545.   endif;
  546.   write( "You see a ", curritem.name );
  547.   if NOT L(255) then
  548.     writeln;
  549.     STOP;
  550.   endif;
  551.   write( ", Type: ", curritem.type );
  552. !
  553. ! The following is a 'cascading if..then..elsif..elsif.....else..endif' 
  554. ! statement.  It is used here to illustrate it's usefulness.  The same
  555. ! code could have been written with a 'ON curritem.type GOTO' statement.
  556. !
  557.   if curritem.type = FOOD or curritem.type = POTION  then
  558.     if curritem.class then
  559.       write( ", Class: ", curritem.class );
  560.       if curritem.class <> CURE then
  561.         write( ", Units: ", curritem.units );
  562.       endif;
  563.     endif;
  564.   elsif curritem.type = WEAPON then
  565.     write( ", Class: ", curritem.class, 
  566.            ", Hands: ", curritem.hands, 
  567.            ", Range: ", curritem.range, 
  568.            ", Damage: ", curritem.damage );
  569.     if curritem.ammoneeded then
  570.       write( ", Needs ammo type: ", curritem.ammo_type );
  571.     endif;
  572.   elsif curritem.type = AMMO then
  573.     write( ", Ammo Type: ", curritem.ammotype );
  574.     if curritem.traptype then
  575.       write( ", Poisoned" );
  576.     endif;
  577.     if curritem.damage then
  578.       write( ", Extra Damage: ", curritem.damage );
  579.     endif;
  580.   elsif curritem.type = ARMOR or curritem.type = SHIELD then
  581.     write( ", Armor Class: ", curritem.ac );
  582.     if curritem.cursed then
  583.       write( " Cursed!" );
  584.     endif;
  585.   elsif curritem.type = AMULET or curritem.type = RING or curritem.type = GEMS then
  586.     if curritem.class then
  587.       write( ", Class: ", curritem.class );
  588.       write( ", Charges: ", curritem.charges );
  589.       if curritem.class <> CURE then
  590.         write( ", Units: ", curritem.units );
  591.         if curritem.permanent then
  592.           write( ", Permanent!" );
  593.         else
  594.           write( ", Temporary" );
  595.         endif;
  596.       endif;
  597.       if curritem.cursed then
  598.         write( ", Cursed!" );
  599.       endif;
  600.     endif;
  601.   elsif curritem.type = SCROLL then
  602.     write( ", Class: ", curritem.class );
  603.   elsif curritem.type = STAFF then
  604.     write( ", Class: ", curritem.class, ", Charges: ", curritem.charges );
  605.   elsif curritem.type = CHEST then
  606.     if curritem.locktype then
  607.       write( ", Locked!" );
  608.       if curritem.traptype = 0 then
  609.         write( ", no traps" );
  610.       elsif curritem.traptype = 1 then
  611.         write( ", poison trap" );
  612.       else
  613.         write( ", bomb damage: ", curritem.traptype );
  614.       endif;
  615.     endif;
  616. ! elsif curritem.type = KEYS     then
  617. !   nothing special about it
  618. ! elsif curritem.type = BOOK     then
  619. !   nothing special about it
  620. ! elsif curritem.type = GOLDSACK then
  621. !   nothing special about it
  622. ! elsif curritem.type = TORCH    then
  623. !   nothing special about it
  624. ! elsif curritem.type = LANTERN  then
  625. !   nothing special about it
  626. ! elsif curritem.type = ROPE     then
  627. !   nothing special about it
  628. ! elsif curritem.type = HOOKS    then
  629. !   nothing special about it
  630. ! elsif curritem.type = MIRROR   then
  631. !   nothing special about it
  632. ! elsif curritem.type = SIGN     then
  633. !   nothing special about it
  634.   elsif curritem.type = VEHICLE then
  635.     write( ", Class: ", curritem.class );
  636. ! else
  637. !   user defined type?
  638.   endif;
  639.   if curritem.weight > 1 and curritem.weight < 256 then
  640.     write( ", Weight: ", curritem.weight );
  641.   endif;
  642.   writeln( "." );
  643.   return;
  644.  
  645. !------------------------------------------------------------------------!
  646. !
  647. ! SUBROUTINE: M1_INVOKE
  648. !
  649. ! Type 1 Magic - Affects the person invoking the magic..
  650. !
  651. ! This portion of the script is invoked whenever an individual in the
  652. ! adventurer's group:
  653. !
  654. !  a) Eats food that has a magical effect
  655. !  b) Drinks a potion with a magical effect
  656. !  c) Successfully wears a ring or an amulet with a magical effect
  657. !  d) Uses a GEM that has a magical effect.
  658. !
  659. ! When invoked, PLAYER is the person that will be affected, and CURRITEM
  660. ! is the item that has the magical effect, and which is either being
  661. ! worn or in the character's backpack.  OBJECT and NPC are not defined.
  662. !
  663. !------------------------------------------------------------------------!
  664. :M1_INVOKE
  665. !------------------------------------------------------------------------!
  666.  
  667.   if curritem.cursed and curritem.permanent then
  668.     curritem.permanent = FALSE;
  669.     writeln( "WARNING: This object was 'cursed' and had 'permanent' effect!" );
  670.     writeln( "WARNING: The effect has been made 'temporary' by OBJECT.SCR" );
  671.   endif;
  672.  
  673.   on curritem.class goto
  674.     M1_NONE,    M1_CURE,    M1_HEAL,    M1_POISON,    M1_RESTORE,
  675.     M1_STR,     M1_DEX,     M1_SPD,     M1_AIM,       M1_AC,
  676.     M1_HP,      M1_IQ,      M1_PWR;
  677.  
  678. :M1_NONE
  679.   writeln( "Nothing happens.." );
  680.   return;
  681.  
  682. :M1_CURE
  683.   if player.poisoned then
  684.     player.poisoned = 0;
  685.     writeln( player.name, " is now cured." );
  686.   else
  687.     writeln( "Nothing happens.." );
  688.   endif;
  689.   return;
  690.  
  691. :M1_HEAL
  692.   if player.hp >= player.mhp then
  693.     writeln( "Nothing happens.." );
  694.   elsif player.hp = 0 then
  695.     writeln( player.name, " is beyond help.." );
  696.   else
  697.     if curritem.units > 0 then
  698.       L(0) = curritem.units;                   ! always heals the same points !
  699.     else
  700.       L(0) = random(player.mhp - player.hp)+1; ! heal a random number of points !
  701.     endif;
  702.     voice( "Tada", 1000 );
  703.     if player.hp + L(0) < player.mhp then
  704.       writeln( player.name, " heals ", L(0), " hit points.." );
  705.       inc( player.hp, L(0) );
  706.     else
  707.       writeln( player.name, " has been completely healed!" );
  708.       player.hp = player.mhp;
  709.     endif;
  710.   endif;
  711.   return;
  712.  
  713. :M1_POISON
  714.   if NOT player.poisoned then
  715.     player.poisoned = 1;
  716.     voice( "Boing", 1000 );
  717.     writeln( "You feel sick.." );
  718.   else
  719.     voice( "Boing", 1000 );
  720.     writeln( "You feel worse.." );
  721.   endif;
  722.   return;
  723.  
  724. :M1_RESTORE
  725.   if player.hp >= player.mhp then
  726.     writeln( "Nothing happens.." );
  727.   elsif player.hp = 0 then
  728.     writeln( player.name, " is beyond help.." );
  729.   else
  730.     voice( "okspell", 1000 );
  731.     player.hp = player.mhp;
  732.     writeln( player.name, " is completely healed!" );
  733.   endif;
  734.   return;
  735.  
  736. :M1_STR
  737.   if curritem.cursed then
  738.     player.str = 0;
  739.     voice( "BOING", 1000 );
  740.     writeln( "Something went wrong.." );
  741.   else
  742.     voice( "okspell", 1000 );
  743.     inc( player.str, curritem.units );
  744.     if curritem.permanent then
  745.       inc( player.mstr, curritem.units );
  746.     endif;
  747.     writeln( player.name, "'s strength increased by ", curritem.units, "!" );
  748.   endif;
  749.   return;
  750.  
  751. :M1_DEX
  752.   if curritem.cursed then
  753.     player.dex = 0;
  754.     voice( "BOING", 1000 );
  755.     writeln( "Something went wrong.." );
  756.   else
  757.     voice( "okspell", 1000 );
  758.     inc( player.dex, curritem.units );
  759.     if curritem.permanent then
  760.       inc( player.mdex, curritem.units );
  761.     endif;
  762.     writeln( player.name, "'s dexterity increased by ", curritem.units, "!" );
  763.   endif;
  764.   return;
  765.  
  766. :M1_SPD
  767.   if curritem.cursed then
  768.     player.spd = 0;
  769.     voice( "BOING", 1000 );
  770.     writeln( "Something went wrong.." );
  771.   else
  772.     voice( "okspell", 1000 );
  773.     inc( player.spd, curritem.units );
  774.     if curritem.permanent then
  775.       inc( player.mspd, curritem.units );
  776.     endif;
  777.     writeln( player.name, "'s speed increased by ", curritem.units, "!" );
  778.   endif;
  779.   return;
  780.  
  781. :M1_AIM
  782.   if curritem.cursed then
  783.     player.aim = 0;
  784.     voice( "BOING", 1000 );
  785.     writeln( "Something went wrong.." );
  786.   else
  787.     voice( "okspell", 1000 );
  788.     inc( player.aim, curritem.units );
  789.     if curritem.permanent then
  790.       inc( player.maim, curritem.units );
  791.     endif;
  792.     writeln( player.name, "'s aim increased by ", curritem.units, "!" );
  793.   endif;
  794.   return;
  795.  
  796. :M1_AC
  797.   if curritem.cursed then
  798.     player.ac = 0;
  799.     voice( "BOING", 1000 );
  800.     writeln( "Something went wrong.." );
  801.   else
  802.     voice( "okspell", 1000 );
  803.     inc( player.ac, curritem.units );
  804.     if curritem.permanent then
  805.       inc( player.mac, curritem.units );
  806.     endif;
  807.     writeln( player.name, "'s armor class increased by ", curritem.units, "!" );
  808.   endif;
  809.   return;
  810.  
  811. :M1_HP
  812.   if curritem.cursed then
  813.     player.hp = player.hp / 3 + 1;
  814.     writeln( player.name, " has been seriously injured!" );
  815.   else
  816.     voice( "okspell", 1000 );
  817.     inc( player.hp, curritem.units );
  818.     if curritem.permanent then
  819.       inc( player.mhp, curritem.units );
  820.     endif;
  821.     writeln( player.name, "'s hit points increased by ", curritem.units, "!" );
  822.   endif;
  823.   return;
  824.  
  825. :M1_IQ
  826.   if curritem.cursed then
  827.     player.iq = 0;
  828.     voice( "BOING", 1000 );
  829.     writeln( "Something went wrong.." );
  830.   else
  831.     voice( "okspell", 1000 );
  832.     inc( player.iq, curritem.units );
  833.     if curritem.permanent then
  834.       inc( player.miq, curritem.units );
  835.     endif;
  836.     writeln( player.name, "'s i.q. increased by ", curritem.units, "!" );
  837.   endif;
  838.   return;
  839.  
  840. :M1_PWR
  841.   if player.class = ELF or player.class = WIZARD then
  842.     if curritem.cursed then
  843.       player.pwr = 0;
  844.       voice( "BOING", 1000 );
  845.       writeln( "Something went wrong.." );
  846.     else
  847.       inc( player.pwr, curritem.units );
  848.       if curritem.permanent then
  849.         inc( player.mpwr, curritem.units );
  850.       endif;
  851.       voice( "okspell", 1000 );
  852.       writeln( player.name, "'s power increased by ", curritem.units, "!" );
  853.     endif;
  854.   else
  855.     voice( "Argh", 1000 );
  856.     write( player.name, " screams and falls to the ground, " );
  857.     if player.hp < 3 then
  858.       writeln( "dead!" );
  859.       player.hp = 0;
  860.     else
  861.       writeln( "holding his head.." );
  862.       dec( player.hp, 2 );
  863.     endif;
  864.   endif;
  865.   return;
  866.  
  867. !------------------------------------------------------------------------!
  868. !
  869. ! SUBROUTINE: M2_INVOKE
  870. !
  871. ! Type 2 Magic - Affects an object or a another person
  872. !
  873. ! This portion of the script handles magic spells which affect objects
  874. ! or persons other than the caster.  When invoked, the PLAYER is the
  875. ! person that invoked the spell and CURRITEM is the object that was used
  876. ! to invoke the spell (which is either being worn or carried by the
  877. ! player).
  878. !
  879. ! The OBJECT and NPC are undefined.  If the spell requires a target,
  880. ! the 'LOCATE' function can be used to select an object or character
  881. ! to cast the spell on.  The locate function returns the distance in blocks
  882. ! to the selected target.  If none is selected, the value is -1, and FAILURE
  883. ! is set.
  884. !
  885. ! After a LOCATE, either OBJECT or NPC will be set depending on whether the
  886. ! user selected an object or a character (or monster, during a fight).
  887. !
  888. ! To figure out which one was selected, check if NPC.COUNT is greater than
  889. ! 0.  If it is, a character was selected.  If it is not, then an object was
  890. ! selected.
  891. !
  892. !------------------------------------------------------------------------!
  893. :M2_INVOKE
  894. !------------------------------------------------------------------------!
  895.  
  896.   if curritem.class = NONE then
  897.     writeln( "Nothing happens.." );
  898.     return;
  899.   endif;
  900.  
  901.   if curritem.count = 0 then
  902.     writeln( "Oops, no object in OBJECT.SCR, m2 invoke" );
  903.     stop;
  904.   endif;
  905.  
  906.   if curritem.class = DAMAGE or curritem.class = CONFUSE or
  907.      curritem.class = SCARE  or curritem.class = PARALYZE or
  908.      curritem.class = KILL then
  909.     if not fighting then
  910.       writeln( "This spell can only be used during a fight.." );
  911.       return;
  912.     endif;
  913.     !
  914.     ! L(5) will contain the TOTAL experience points gained when done..
  915.     ! L(6) is the maximum damage that will be done to a single monster..
  916.     ! L(8) is the maximum total damage that can be done to a group of monsters..
  917.     ! L(9) is the TOTAL number of monsters affected AFTER the spell
  918.     !
  919.     L(5) = 0;
  920.     L(6) = player.level + adjustments(player.pwr) / 2 + 1;
  921.     if L(6) <= 0 then
  922.       writeln( "The spell failed.." );
  923.       STOP;
  924.     endif;
  925.     if curritem.units then
  926.       L(8) = curritem.units;
  927.     else
  928.       L(8) = player.iq + adjustments(player.iq);
  929.     endif;
  930.     L(9) = 0;
  931.   endif;
  932.  
  933.   if curritem.type = STAFF and curritem.charges = 0 then
  934.     writeln( "The ", curritem.name, " doesn't work.." );
  935.     return;
  936.   endif;
  937.      
  938.   if curritem.class <> LEAVE  and
  939.      curritem.class <> ZOOM   and
  940.      curritem.class <> INFORM and
  941.      curritem.class <> DOORS  and
  942.      curritem.class <> RESURRECT then
  943.     write( curritem.class, " what:" );
  944.     L(1) = locate;  ! SETS THE TARGET FOR THE SPELL ! 
  945.     if L(1) = 0 then
  946.       writeln( "nothing.." );
  947.       return;
  948.     endif;
  949.     ! Either NPC.COUNT or OBJECT.COUNT identifies selected object/char !
  950.     if npc.count then ! It's a character, not an object..
  951.       if npc.type = HOSTILE then
  952.         writeln( npc.name );  ! monster's don't have classes.. !
  953.       else
  954.         writeln( npc.class ); ! Human, elf, dwarf, etc..       !
  955.       endif;
  956.       if curritem.class = DESTROY  or curritem.class = DUPLICATE or
  957.          curritem.class = RECHARGE or curritem.class = FLOAT then
  958.         writeln( "This spell only work's on objects!" );
  959.         goto M2_EXIT;
  960.       endif;
  961.     else
  962.       writeln( object.type );  ! Food, weapon, ring, etc..      !
  963.     endif;
  964.   endif;
  965.  
  966.   on curritem.class goto 
  967.     M2_EXIT,     M2_DESTROY,  M2_DUPLICATE, M2_LEAVE,
  968.     M2_RESURRECT,M2_INFORM,   M2_LOCATE,    M2_KILL, 
  969.     M2_CONFUSE,  M2_SCARE,    M2_DAMAGE,    M2_PARALYZE,
  970.     M2_RECHARGE, M2_FLOAT,    M2_ANALYZE,   M2_ZOOM;
  971.  
  972. :M2_NONE      ! No magic..
  973.   writeln( "Nothing happens.." );
  974.   goto M2_EXIT;
  975.  
  976. :M2_DESTROY   ! Destroy an object                      pwr = 5, rng=10
  977.   ! if player.pwr < 5 goto M2_NOPOWER; ! No power check needed
  978.   if L(1) > 10 goto M2_OUTOFRANGE;
  979.   voice( "Explode", 1000 );
  980.   writeln( "The ", object.type, " is destroyed.." );
  981.   vanish( object );
  982.   L(4) = 5;
  983.   goto M2_EXIT;
  984.  
  985. :M2_DUPLICATE ! Duplicates an object                   pwr = 40, rng=1
  986.   ! if player.pwr < 40 goto M2_NOPOWER; ! No power check needed
  987.   if L(1) > 1 goto M2_OUTOFRANGE;
  988.   inc( object.count, 1 ); ! Creates an identical copy ! 
  989.   L(4) = 40;
  990.   goto M2_EXIT;
  991.  
  992. :M2_LEAVE     ! Exit through the 'exit' door from anywhere...  
  993.   if world.type <> DUNGEON then
  994.     voice( "Boing", 1000 );
  995.     writeln( "This spell only work's in dungeons.." );
  996.     return;
  997.   endif;
  998.   ! if player.pwr < 5 goto M2_NOPOWER; ! No power check needed
  999.   enter( world.edgedoor );
  1000.   voice( "okspell", 1000 );
  1001.   writeln( "You leave this level of the dungeon.." );
  1002.   L(4) = 5;
  1003.   goto M2_EXIT;
  1004.  
  1005. :M2_RESURRECT ! Revive a DEAD person                   pwr = 50, rng=1
  1006.   ! if player.pwr < 50 goto M2_NOPOWER; ! No power check needed
  1007.   if L(1) > 1 goto M2_OUTOFRANGE;
  1008.   write( "Resurrect: " );
  1009.   L0 = select( group );
  1010.   stats( L0 );
  1011.   if player.hp > 0 then
  1012.     voice( "Boing", 1000 );
  1013.     writeln( "This player is NOT dead!" );
  1014.     return;
  1015.   endif;
  1016.   voice( "okspell", 1000 );
  1017.   writeln( player.name );
  1018.   player.hp  = 2;
  1019.   writeln( player.name, " is alive, but weak.." );
  1020.   L(4) = 50;
  1021.   goto M2_EXIT;
  1022.   
  1023. :M2_INFORM    ! Displays some text                     pwr =  5
  1024.   ! if player.pwr < 5 goto M2_NOPOWER; ! No power check needed
  1025.   if L(1) > 5 goto M2_OUTOFRANGE;
  1026.   loadhint;
  1027.   writeln( "The wind seems to carry a random phrase to your ears.." );
  1028.   writeln( s0 );
  1029.   L(4) = 5;
  1030.   goto M2_EXIT;
  1031.  
  1032. :M2_LOCATE    ! Locate doors                           pwr = 10
  1033.   ! if player.pwr < 10 goto M2_NOPOWER; ! No power check needed
  1034.   if L(1) > 10 goto M2_OUTOFRANGE;
  1035.   L(0) = 0;
  1036.   :LDLOOP
  1037.     if world.doorx(L0) > 0 and world.doory(L0) > 0 then
  1038.       frame( world.doorx(L0), world.doory(L0), SYS_FRAME );
  1039.     endif;
  1040.     inc(L0);
  1041.   if L(0) < 16 goto LDLOOP;
  1042.   L(4) = 10;
  1043.   goto M2_EXIT;
  1044.  
  1045. :M2_KILL      ! Kill 1 enemy during battle             pwr = 20, rng=6
  1046.   writeln( npc.name, " killed. +", npc.hp, " exp." );
  1047.   inc( player.exp, npc.hp );
  1048.   npc.count = 0;
  1049.   STOP;
  1050.  
  1051. :M2_DAMAGE    ! Causes damage to monsters              pwr =  5, rng=12
  1052.   S0 = "hit";
  1053.   foreach npc do
  1054.     L(7) = min( npc.hp, random(L6) );  ! How much damage to this one monster?
  1055.     if L(7) > 0 then
  1056.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  1057.       write( npc.name );
  1058.       if L(7) < npc.hp then
  1059.         write( " hit." );
  1060.         dec( npc.hp, L(7) );           ! Hit the monster..
  1061.       else
  1062.         write( " killed!" );
  1063.         npc.count = 0;
  1064.       endif;
  1065.       writeln( " +", L(7), " exp." );
  1066.       inc(L9);                       ! Count of affected npcs
  1067.       inc( L(5), L(7) );                 ! Accumulate experience..
  1068.       if L(5) > L(8) goto DCSPEXIT;      ! Stop when total of L(8) points used
  1069.     endif;
  1070.   endfor;  
  1071.   goto DCSPEXIT;
  1072.  
  1073. :M2_CONFUSE   ! Makes monsters shoot at other monsters pwr =  1, rng=12
  1074.   S0 = "confused";
  1075.   foreach npc do
  1076.     L(7) = min( npc.hp, random(L6) );  ! How much confusion to this one monster?
  1077.     if L(7) > 0 and npc.confused = 0 then
  1078.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  1079.       inc(L9);                       ! Count of affected npcs
  1080.       npc.confused = L(7);             ! Confuse for 'n' units
  1081.       inc( L(5), L(7) );                 ! Accumulate experience..
  1082.       if L(5) > L(8) goto DCSPEXIT;      ! Stop when total of L(8) points used
  1083.     endif;
  1084.   endfor;  
  1085.   goto DCSPEXIT;
  1086.  
  1087. :M2_SCARE     ! Scares monsters                        pwr =  2, rng=12
  1088.   S0 = "scared";
  1089.   foreach npc do
  1090.     L(7) = min( npc.hp, random(L6) );  ! How much 'fright' to this one monster?
  1091.     if L(7) > 0 and npc.scared = 0 then
  1092.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  1093.       inc(L9);
  1094.       npc.scared = L(7);               ! Frighten for 'n' units
  1095.       inc( L(5), L(7) );                 ! Accumulate experience..
  1096.       if L(5) > L(8) goto DCSPEXIT;      ! Stop when total of L(8) points used
  1097.     endif;
  1098.   endfor;  
  1099.   goto DCSPEXIT;
  1100.  
  1101. :M2_PARALYZE  ! Monster can't move                     pwr =  5, rng=12
  1102.   S0 = "paralyzed";
  1103.   foreach npc do
  1104.     L(7) = min( npc.hp, random(L6) );  ! How much paralysis to this one monster?
  1105.     if L(7) > 0 and npc.paralyzed = 0 then
  1106.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  1107.       inc(L9);
  1108.       npc.paralyzed = L(7);            ! Paralyze for 'n' units
  1109.       inc( L(5), L(7) );                 ! Accumulate experience..
  1110.       if L(5) > L(8) goto DCSPEXIT;      ! Stop when total of L(8) points used
  1111.     endif;
  1112.   endfor;  
  1113.   goto DCSPEXIT;
  1114.  
  1115. :M2_RECHARGE  ! Recharge an ITEM                       pwr = 25, rng=1
  1116.   ! if player.pwr < 25 goto M2_NOPOWER; ! No power check needed
  1117.   if L(1) > 1 goto M2_OUTOFRANGE;
  1118.   if object.type = RING or object.type = AMULET or object.type = STAFF then
  1119.     inc( object.charges, random(player.level)+1 );
  1120.     voice( "okspell", 1000 );
  1121.     writeln( "The ", object.type, " now has ", object.charges, " charges." );
  1122.   else
  1123.     voice( "Boing", 1000 );
  1124.     writeln( "The smell of rotten eggs fills the air.." );
  1125.   endif;
  1126.   L(4) = 25;
  1127.   goto M2_EXIT;
  1128.  
  1129. :M2_FLOAT     ! Remove an object's weight              pwr = 10, rng=1
  1130.   ! if player.pwr < 10 goto M2_NOPOWER; ! No power check needed
  1131.   if L(1) > 1 goto M2_OUTOFRANGE;
  1132.   if object.weight < 255 then
  1133.     object.weight = object.weight / 2 + 1;
  1134.     voice( "okspell", 1000 );
  1135.     writeln( "The ", object.type, " is now much lighter.." );
  1136.   else
  1137.     voice( "Boing", 1000 );
  1138.     writeln( "It's didn't work.  The ", object.type, " is too heavy." );
  1139.   endif;
  1140.   L(4) = 10;
  1141.   goto M2_EXIT;
  1142.  
  1143. :M2_ANALYZE   ! Discover object's properties           pwr = 10, rng=1
  1144.   ! if player.pwr < 10 goto M2_NOPOWER; ! No power check needed
  1145.   if L(1) > 1  goto M2_OUTOFRANGE;
  1146.   L(255) = TRUE;   ! Give DETAILED description !
  1147.   gosub DESCRIBE;
  1148.   L(4) = 10;
  1149.   goto M2_EXIT;
  1150.  
  1151. :M2_ZOOM      ! View the world.. 
  1152.   ! if player.pwr < 25 goto M2_NOPOWER; ! No power check needed
  1153.   viewpcx( world );
  1154.   if success then
  1155.     pause;
  1156.   endif;
  1157.   paint( screen ); ! If you don't have any WORLD###.PCX files, you can use !
  1158.                    ! paint( WINDOW ) instead of paint( SCREEN) !
  1159.   L(4) = 25;
  1160.   goto M2_EXIT;
  1161.  
  1162. :M2_NOPOWER
  1163.   writeln( "You don't have enough power!" );
  1164.   return;
  1165.  
  1166. :M2_OUTOFRANGE
  1167.   writeln( "You are too far away from the ", object.name );
  1168.   return;
  1169.  
  1170. :DCSPEXIT
  1171.   if L(9) then
  1172.     write( L(9), " foes were ", S0 );
  1173.     if L(5) then  
  1174.       writeln( " for a total of +", L(5), " experience!" );
  1175.       inc( player.exp, L(5) );           ! Grant experience..
  1176.     else
  1177.       writeln( " With no effect" );
  1178.     endif;
  1179.   else
  1180.     writeln( "No effect.." );
  1181.   endif;
  1182.   goto M2_EXIT;
  1183.  
  1184. :M2_EXIT
  1185.   if curritem.count > 0 then
  1186.     if curritem.count > 1 then
  1187.       curritem.name = curritem.class;
  1188.     endif;
  1189.     if curritem.type = SCROLL then
  1190.       dec( curritem.count ); ! Item disapears if count reaches 0 !
  1191.     elsif curritem.type = STAFF then
  1192.       dec( curritem.charges ); ! One less !
  1193.     endif;
  1194.   else
  1195.     dec( player.pwr, L(4) );   ! A spell !
  1196.   endif;
  1197.   return;
  1198.  
  1199. !------------------------------------------------------------------------!
  1200. :UNLOCK_OBJECT
  1201. !------------------------------------------------------------------------!
  1202.    L0 = 0;
  1203.    L1 = curritem.index;
  1204.    L2 = curritem.locktype;
  1205.    :UCLOOP
  1206.       setbp( player, L0 );
  1207.       if player.bp.count then
  1208.         if player.bp.type = KEYS and player.bp.keytype = L2 then
  1209.           write( "You use the ", player.bp.name, " to unlock the " );
  1210.           setbp( player, L1 ); ! Recover the 'curritem' !
  1211.           writeln( curritem.name );
  1212.           curritem.locktype = 0;
  1213.           if curritem.block2 then
  1214.             L0 = curritem.block2;
  1215.             curritem.block  = curritem.block2;
  1216.             curritem.block2 = L0;
  1217.           endif;
  1218.           return;
  1219.         endif;
  1220.       endif;
  1221.       inc( L0 );
  1222.       if L0 < 16 goto :UCLOOP;
  1223.    RETURN;
  1224.  
  1225.  
  1226.